#ifndef __JOY_STICK_H__
#define __JOY_STICK_H__

#include <Arduino.h>

class Joystick
{
    public:
        void attach (int pin_x, int pin_y, void (*on_attached)(void));
        void check (void (*on_change)(uint32_t value));

    private:
        struct 
        {
            uint8_t en_x, en_y;
            uint16_t x, y;
        } data;
    
        int pin_x, pin_y;
        int x, y, bx, by;
        int vx, vy, vx0, vy0;
        uint32_t value;

        void init ();
        int _map2 (int n, int base);
};
#endif //__JOY_STICK_H__
